var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    listname: -1,
    skillData:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    wx.showToast({
      title: '加载中',
      icon: 'loading',
      duration: 10000
    })
    const db = wx.cloud.database();
    try {
      db.collection('pilotweaponskill').get({
        success: res => {
          var standardarr=[];
          var durabilityearr = [];
          var repairarr=[];
          for (var i in res.data){
            var data=JSON.parse(res.data[i].data)
            if (data.type=="1"){
              standardarr.push(data)
            }
            if (data.type == "2") {
              durabilityearr.push(data)
            }
            if (data.type == "3") {
              repairarr.push(data)
            }
          }
          var standardobj={
            title:"标准技能",
            value: standardarr
          }
          var durabilityeobj = {
            title: "特殊武器技能",
            value: durabilityearr
          }
          var repairobj = {
            title: "特殊防御技能",
            value: repairarr
          }
         

          var corearr = [standardobj, durabilityeobj, repairobj]

          this.setData({
            skillData: corearr
          })
          wx.hideToast();
        },
        fail: err => {
          wx.showToast({
            icon: 'none',
            title: '查询记录失败'
          })
          wx.hideToast();
        }
      })
    } catch (e) {
      wx.showToast({
        title: '读取数据失败，请检查网络',
        icon: 'none',
        duration: 10000
      })
    }
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
  },

  listactive: function (e) {
    this.setData({ listname: e.currentTarget.dataset.listname })
  },

})